#include <memory>
#include <vector>
#include <string>
#include <CivetServer.h>
#include <unistd.h>

using namespace std;

unique_ptr<CivetServer> server;

class RootHandler : public CivetHandler
{
public:
    bool handleGet(CivetServer *server, struct mg_connection *conn)
    {
        mg_printf(conn,
                  "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"
                  "<html><body>Hello World!</body></html>");
        return true;
    }
};

class DefaultCallbacks : public CivetCallbacks
{
public:
    void *
	getContext(CivetServer *server, const struct mg_connection *conn)
    {
        return server;
    }
};


int main(int argc, char *argv[])
{
    vector<string> options{
        "document_root", ".",
        "num_threads", "100",
        "listening_ports", "8080"
    };
    
    unique_ptr<CivetCallbacks> callbacks = make_unique<CivetCallbacks>();

    server = make_unique<CivetServer>(
        options,
        callbacks.get(),
        nullptr);
    
    auto ptr_root_handler = make_unique<RootHandler>();

    // server->addHandler("/", ptr_root_handler.get());

    sleep(9999);

    return 0;
}
